package com.icow.wms.basic.scheduled;

import HslCommunication.Authorization;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.lang.reflect.Field;

@Service
@Slf4j
public class UpdateAuthority {

    @Scheduled(fixedDelay = 1000 * 60 * 60)
    public void refresh() throws NoSuchFieldException, IllegalAccessException {
        Field f = Authorization.class.getDeclaredField("niasdhasdguawdwdad");
        f.setAccessible(true);
        Field a = Authorization.class.getDeclaredField("naihsdadaasdasdiwasdaid");
        a.setAccessible(true);
        if (a.get(null) != f.get(null)) {
            a.setInt(null, f.getInt(null));
        }
        Field b = Authorization.class.getDeclaredField("nuasgdaaydbishdgas");
        b.setAccessible(true);
        if (b.getInt(null) <= 0) {
            b.setInt(null, 1);
        }
    }
}
